package com.ruoyi.project.tool.swagger.UserController;

import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.annotation.SignatureValidation;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.framework.interceptor.annotation.RepeatSubmit;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.framework.web.page.TableDataInfo;
import com.ruoyi.project.system.domain.SysParise;
import com.ruoyi.project.system.service.ISysPariseService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 平台瞬间点赞Controller
 *
 * @author jjp
 * @date 2020-04-14
 */
@RestController
@Api(description = "用户精彩瞬间点赞")
@RequestMapping("/mobileUser/parise")
public class UserPariseController extends BaseController {
    @Autowired
    private ISysPariseService sysPariseService;

    /**
     * 查询平台瞬间点赞列表
     */
    @SignatureValidation
    @ApiOperation("查询平台瞬间点赞列表")
    @GetMapping("/list")
    public TableDataInfo list(SysParise sysParise) {
        startPage();
        List<SysParise> list = sysPariseService.selectSysPariseList(sysParise);
        return getDataTable(list);
    }

    /**
     * 获取瞬间点赞详细信息
     */
    @SignatureValidation
    @ApiOperation("获取平台瞬间点赞详细信息")
    @GetMapping(value = "/{pariseId}")
    public AjaxResult getInfo(@PathVariable("pariseId") Long pariseId) {
        return AjaxResult.success(sysPariseService.selectSysPariseById(pariseId));
    }

    /**
     * 新增平台瞬间点赞
     */
    @RepeatSubmit
    @SignatureValidation
    @ApiOperation("新增平台瞬间点赞")
    @Log(title = "平台瞬间点赞", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysParise sysParise) {
        sysPariseService.insertSysParise(sysParise);
        int count = sysPariseService.selectCount();
        return toAjax(count);
    }
    /**
     * 删除平台瞬间点赞
     */
    @SignatureValidation
    @ApiOperation("删除平台瞬间点赞")
    @Log(title = "平台瞬间点赞", businessType = BusinessType.DELETE)
    @DeleteMapping("/{pariseIds}")
    public AjaxResult remove(@PathVariable Long[] pariseIds) {
        sysPariseService.deleteSysPariseByIds(pariseIds);
        int count = sysPariseService.selectCount();
        return toAjax(count);
    }

    /**
     * 获取平台瞬间点赞详细信息
     */
    @ApiOperation("获取瞬间点赞详细信息")
    @SignatureValidation
    @GetMapping(value = "/getMomentIdInfo/{momentId}")
    public TableDataInfo getMomentIdInfo(@PathVariable("momentId") Long momentId) {
        startPage();
        List<SysParise> sysParises = sysPariseService.selectSysPariseMomentId(momentId);
        return getDataTable(sysParises);
    }
}
